<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>
	<body>
		<script>
			/**
			 * 数字转整数 如 100000 转为10万,保留整数
			 * 不满10万时，换算为元，页面不展示单位
			 * @param {需要转化的数} num
			 */
			function tranNumber(num) {
				var numStr = num.toString()
				if (numStr.length <= 6) {
					return parseFloat(num)
				}
				if (numStr.length > 6) {
					var decimal = numStr.substring(
						numStr.length - 4,
						numStr.length - 4
					)
					return parseInt(num / 10000) + decimal + '万'
				}
			}
			console.log(tranNumber(577832.2)) //57万
			// console.log(tranNumber(50813)) //50813
		</script>
	</body>
</html>
